#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT(coroutine_event, 1.0.0, colaghostno.1@gmail.com)
AC_CONFIG_SRCDIR([src/task.c])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(coroutine_event, 1.0.0)

LIBEVENT_PREFIX="NONE"
AC_ARG_WITH(libevent, [  --with-libevent=prefix of libevent installation.e.g./usr/local or /usr], [LIBEVENT_PREFIX=$withval], [LIBEVENT_PREFIX="/usr/local"])
AC_SUBST(LIBEVENT_PREFIX)
LIBEVENT_URL=http://www.monkey.org/~provos/libevent/
AC_CACHE_CHECK([for libevent directory], ac_cv_libevent_dir, [
    le_found=no
    for ledir in $LIBEVENT_PREFIX "" $prefix /usr/local ; do
      if test ! -z "$ledir" -a ! -d "$ledir" ; then
        continue;
      fi
      if test ! -z "$ledir" ; then
        if test -d "$ledir/lib" ; then
          if test -f "$ledir/lib/libevent.so" ; then
            le_found=yes
            ac_cv_libevent_dir=$ledir
            break
          fi
        fi
      fi
    done
    if test $le_found = no; then
      AC_MSG_ERROR([libevent is required.If it's already installed, specify its path uing --with-libevent])
    fi
    ])

AC_PROG_RANLIB

# Checks for programs.
AC_PROG_CC

# Checks for libraries.
AC_CHECK_LIB([pthread], [pthread_mutex_init])

# Checks for header files.
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([memmove memset socket strerror])

AC_PROG_LIBTOOL

AC_OUTPUT([Makefile src/Makefile test/Makefile])
